﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using AvatarHelper;
using Avatar.Model;

public partial class Company_Account : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Membership.GetUser() != null)
        {
            var _user=Membership.GetUser();

            using(var _adc=DBHelper.GetDataContext())
            {
                var _company = _adc.CompanyInformation.Where(c => c.User == _user.UserName).FirstOrDefault();
                if (_company != null)
                {
                    link_UserName.Text = _company.CompanyName;
                    link_UserName.NavigateUrl = "~/CompanyJobList.aspx?Company="+_company.CompanyName;
                    link_UserName.Target = "_blank";
                }

                var _financialAccount = _adc.CompanyFinancialAccount.Where(c => c.Company == _user.UserName).FirstOrDefault();
                if (_financialAccount != null)
                {
                    lbl_Money.Text = _financialAccount.Balance.ToString();
                }
                else
                {
                    lbl_Money.Text = "0.00";
                }

                var _companyService = _adc.CompanyService.Where(s => s.Company == _user.UserName).FirstOrDefault();
                if (_companyService != null)
                {
                    lbl_ServiceType.Text = _companyService.CompanyServiceType.TypeName;
                }
            }
        }
    }
}
